package dao;

import entity.User;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;

public class UserInfo {
    public static User getInfo(String id){
        String sql="select id,name,telephone,identity_ from account where id =?";
        try {
            Connection conn=DataBaseConnect.getConnection();
            PreparedStatement pstmt=conn.prepareStatement(sql);
            pstmt.setString(1,id);
            ResultSet rs=pstmt.executeQuery();
            while (rs.next()){
                return new User(rs.getString(1),rs.getString(2),rs.getString(3),rs.getString(4));
            }
        }catch (Exception e){
            System.out.println("获取用户信息error");
            e.printStackTrace();
        }
        return null;
    }
}
